# Maintainer: David Runge <dvzrv@archlinux.org>

_name=libtmux
pkgname=python-libtmux
pkgver=0.21.1
pkgrel=2
pkgdesc="Python api for tmux"
arch=(any)
url="https://libtmux.git-pull.com/"
license=(MIT)
depends=(
  python
  python-typing-extensions
  tmux
)
makedepends=(
  python-build
  python-installer
  python-poetry-core
  python-wheel
)
checkdepends=(
  python-pytest
  procps-ng
)
optdepends=('python-pytest: for pytest plugin')
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('a5225d0154f7c08b46b38e77c64b0779075eba59e8ed9708e675eaebc2845e663269ab8df90812b40c7b0b9a5cd25a71fdc0146e2288ca0970605c6ab0ff4bd0')
b2sums=('1e25edcad6fdb396b0f319fd83a3ca41c9643580ea53ec66e47d88fcd07fe5969335ddeb29b3abf6239d559cd879ea9b40b3e1063e8d09c8ea112e0b5b111cc6')

build() {
  cd $_name-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$PWD/test_dir/$_site_packages"
  pytest -vv tests
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
  install -vDm 644 {CHANGES,README.md} -t "$pkgdir/usr/share/doc/$pkgname"
}
